package com.dididoctor.patient.Activity.PicScan;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

import com.dididoctor.patient.Ui.ZoomImageView;
import com.dididoctor.patient.Utils.LoaderImage;

import java.util.List;

/**
 * 项目名称：Psd
 * 类描述：查看图片界面中ViewPager的适配器
 * 创建人：张强
 * 创建时间：2015/6/27 10:16
 * 修改人：
 * 修改时间：2015/6/27 10:16
 * 修改备注：
 */
public class ImageAdapter extends PagerAdapter {
    private List<ZoomImageView> data;
    private Context context;
    private LoaderImage loader;
    private List<String> image_urls;

    public ImageAdapter(Context context, List<ZoomImageView> data, List<String> image_urls) {
        this.context = context;
        this.data = data;
        loader = new LoaderImage(this.context);
        this.image_urls = image_urls;

    }

    @Override
    public int getCount() {
        return data.size();
    }


    public void setData(List<ZoomImageView> data) {
        this.data = data;
        notifyDataSetChanged();
        ;
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {

        return arg0 == arg1;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ((ViewPager) container).addView(data.get(position));
        return data.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);

    }

}
